package com.jeethink.user.controller;

import com.jeethink.common.core.web.controller.BaseController;
import com.jeethink.common.core.web.domain.AjaxResult;
import com.jeethink.common.core.web.page.TableDataInfo;
import com.jeethink.common.log.annotation.Log;
import com.jeethink.common.log.enums.BusinessType;
import com.jeethink.user.domain.ArgUserMar;
import com.jeethink.user.service.IArgUserMarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 【请填写功能名称】Controller
 * 
 * @author jeethink
 * @date 2020-10-14
 */
@RestController
@RequestMapping("/user")
public class ArgUserMarController extends BaseController
{
    @Autowired
    private IArgUserMarService argUserMarService;

    /**
     * 查询【用户】列表
     */
    @PreAuthorize("@ss.hasPermi('backstage:user:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArgUserMar argUserMar)
    {
        startPage();
        List<ArgUserMar> list = argUserMarService.selectArgUserMarList(argUserMar);
        return getDataTable(list);
    }
    /**
     * 获取【请填写功能名称】详细信息
     */
    @PreAuthorize("@ss.hasPermi('backstage:user:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return AjaxResult.success(argUserMarService.selectArgUserMarById(userId));
    }
    /**
     * 新增【用户】
     */
    @PreAuthorize("@ss.hasPermi('backstage:user:add')")
    @Log(title = "【新增用户】", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArgUserMar argUserMar)
    {
        return toAjax(argUserMarService.insertArgUserMar(argUserMar));
    }

    /**
     * 修改【用户】
     */
    @PreAuthorize("@ss.hasPermi('backstage:user:edit')")
    @Log(title = "【修改用户】", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArgUserMar argUserMar)
    {
        return toAjax(argUserMarService.updateArgUserMar(argUserMar));
    }

    /**
     * 删除【用户】
     */
    @PreAuthorize("@ss.hasPermi('backstage:user:remove')")
    @Log(title = "【删除用户】", businessType = BusinessType.DELETE)
    @DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(argUserMarService.deleteArgUserMarByIds(userIds));
    }
}
